package com.mzq.langchain4j_springboot.web.upload;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
public class UploadController {

    @Autowired
    AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public String upload(@RequestParam("image")MultipartFile image) throws IOException {
        log.info("文件上传{}",image.getOriginalFilename());
        //调用工具类
        String url = aliOSSUtils.upload(image);
        log.info("文件上传完成，文件url:",url);
        return url;
    }
}
